import warnings

warnings.warn("qturboframe.public_ui_ufc_wpf.utili.common模块已被废弃，替代模块为qturboframe.lib.utilis.CommonScripts", DeprecationWarning)
import wmi

class Common(object):
    @staticmethod
    def update_special_character(str):
        '''
        把字符串中的正则表达式特殊字符替换为标识普通字符

        :Args:
         - str: 字符串

        :Returns:
            None

        :Example:
         - 例: Common.update_special_character('width(宽度)')
        '''
        re_special_character = {'.': '\.'
            , '*': '\*'
            , '(': '\('
            , ')': '\)'
            , '$': '\$'
            , '+': '\+'
            , '[': '\['
            , ']': '\]'
            , '?': '\?'
            , '{': '\{'
            , '|': '\|'}
        for key, value in re_special_character.items():
            str = str.replace(key, value)

        # #\s匹配任何空白字符
        # str = str.replace(" ","\s")
        return str

    @staticmethod
    def kill_process_by_name(process_name):
        '''
        根据进程名关闭进程

        :Args:
         - process_name: 进程名

        :Returns:
            None

        :Example:
         - 例: Common.kill_process_by_name('QuantShell.exe')
        '''
        c = wmi.WMI()
        for process in c.Win32_Process(name=process_name):
            process.Terminate()

if __name__ == '__main__':
    str = "登    录"
    print(str.replace(" "," "))
